// internal/apps/auth/serializers/user_serializer.go
package serializers

import (
	"time"
)

// CreateUserRequest 创建用户请求
type CreateUserRequest struct {
	Username string `json:"username" binding:"required,min=3,max=20" example:"admin"`
	Email    string `json:"email" binding:"required,email" example:"admin@example.com"`
	Password string `json:"password" binding:"required,min=6" example:"123456"`
	RoleID   uint   `json:"role_id" binding:"required" example:"1"`
}

// UpdateUserRequest 部分更新用户请求
type UpdateUserRequest struct {
	Username *string `json:"username,omitempty" binding:"omitempty,min=3,max=20" example:"admin"`
	Email    *string `json:"email,omitempty" binding:"omitempty,email" example:"admin@example.com"`
	RoleID   *uint   `json:"role_id,omitempty" example:"1"`
}

// UpdateUserWholeRequest 完整更新用户请求
type UpdateUserWholeRequest struct {
	Username string `json:"username" binding:"required,min=3,max=20" example:"admin"`
	Email    string `json:"email" binding:"required,email" example:"admin@example.com"`
	RoleID   uint   `json:"role_id" binding:"required" example:"1"`
}

// ChangePasswordRequest 修改密码请求
type ChangePasswordRequest struct {
	OldPassword string `json:"old_password" binding:"required" example:"oldpassword"`
	NewPassword string `json:"new_password" binding:"required,min=6" example:"newpassword"`
}

// UserResponse 用户响应
type UserResponse struct {
	ID        uint      `json:"id" example:"1"`
	Username  string    `json:"username" example:"admin"`
	Email     string    `json:"email" example:"admin@example.com"`
	RoleID    uint      `json:"role_id" example:"1"`
	RoleName  string    `json:"role_name" example:"管理员"`
	CreatedAt time.Time `json:"created_at" example:"2023-01-01T00:00:00Z"`
	UpdatedAt time.Time `json:"updated_at" example:"2023-01-01T00:00:00Z"`
}

// UserListRequest 用户列表请求
type UserListRequest struct {
	Page     int    `form:"page,default=1" binding:"min=1" example:"1"`
	PageSize int    `form:"page_size,default=10" binding:"min=1,max=100" example:"10"`
	Username string `form:"username" example:"admin"`
	Email    string `form:"email" example:"admin@example.com"`
	RoleID   uint   `form:"role_id" example:"1"`
}

// UserListResponse 用户列表响应
type UserListResponse struct {
	List       []UserResponse `json:"list"`
	Total      int64          `json:"total" example:"100"`
	Page       int            `json:"page" example:"1"`
	PageSize   int            `json:"page_size" example:"10"`
	TotalPages int            `json:"total_pages" example:"10"`
}

// UserDetailResponse 用户详情响应
type UserDetailResponse struct {
	ID          uint                 `json:"id" example:"1"`
	Username    string               `json:"username" example:"admin"`
	Email       string               `json:"email" example:"admin@example.com"`
	RoleID      uint                 `json:"role_id" example:"1"`
	Role        RoleResponse         `json:"role"`
	Permissions []PermissionResponse `json:"permissions"`
	CreatedAt   time.Time            `json:"created_at" example:"2023-01-01T00:00:00Z"`
	UpdatedAt   time.Time            `json:"updated_at" example:"2023-01-01T00:00:00Z"`
}

// RoleResponse 角色响应
type RoleResponse struct {
	ID          uint      `json:"id" example:"1"`
	Name        string    `json:"name" example:"管理员"`
	Code        string    `json:"code" example:"admin"`
	Description string    `json:"description" example:"系统管理员角色"`
	Permissions []string  `json:"permissions,omitempty" example:"user:manage,role:manage"`
	CreatedAt   time.Time `json:"created_at,omitempty" example:"2023-01-01T00:00:00Z"`
	UpdatedAt   time.Time `json:"updated_at,omitempty" example:"2023-01-01T00:00:00Z"`
}

// PermissionResponse 权限响应
type PermissionResponse struct {
	Resource string `json:"resource" example:"user"`
	Action   string `json:"action" example:"create"`
}
